package com.moorror.codegenvel.utils;

import com.intellij.openapi.editor.Document;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;

/**
 * @Author jiyanghuang
 * @Date 2025/10/1 01:44
 */
public class VirtualFileUtils {

    public static String content(Project project, VirtualFile virtualFile){
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        if (psiFile != null) {
            Document document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
            if (document != null) {
                return document.getText();
            }
        }
        return "";
    }
}
